package com.maoxx.stuchoosemssbv_service.mapper;

import com.maoxx.stuchoosemssbv_service.entity.CourseTeacherInfo;
import com.maoxx.stuchoosemssbv_service.entity.SCTInfo;
import com.maoxx.stuchoosemssbv_service.entity.StudentCourseTeacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SCTMapper {
    List<SCTInfo> getSCTInfo();

    public List<SCTInfo> findBySearch(@Param("sid") Integer sid,
                                       @Param("sname") String sname,
                                       @Param("sFuzzy") Integer sFuzzy,
                                       @Param("cid") Integer cid,
                                       @Param("cname") String cname,
                                       @Param("cFuzzy") Integer cFuzzy,
                                       @Param("tid") Integer tid,
                                       @Param("tname") String tname,
                                       @Param("tFuzzy") Integer tFuzzy,
                                       @Param("lowBound") Integer lowBound,
                                       @Param("highBound") Integer highBound,
                                       @Param("term") String term);

    @Update("UPDATE sct SET sct.grade = #{grade} WHERE sct.sid = #{sid} AND sct.tid = #{tid} AND sct.cid = #{cid} AND sct.term = #{term}")
    public boolean updateById(@Param("sid") Integer sid,
                              @Param("cid") Integer cid,
                              @Param("tid") Integer tid,
                              @Param("term") String term,
                              @Param("grade") Integer grade);

    @Delete("DELETE FROM sct WHERE sid = #{sct.sid} AND tid = #{sct.tid} AND cid = #{sct.cid}")
    public boolean deleteBySCT(@Param("sct") StudentCourseTeacher sct);

    List<CourseTeacherInfo> findByStudentId(@Param("sid") Integer sid,@Param("term") String term);

    @Select("SELECT DISTINCT sct.term FROM sct sct")
    List<String> findAllTerm();
}
